<div class="section_wrapper">
    <h3 class="title_black"><?php echo __('tickets'); ?></h3>
    <div class="content toggle no_padding">
        <?php $this->load->view('ticket/search_form'); ?>
        <table style="width: 100%;">
            <tr>
                <th scope="col" class="first"><?php echo __('id'); ?></th>
                <th scope="col" ><?php echo __('name_of_ticket'); ?></th>
                <th scope="col"><?php echo __('category'); ?></th>
                <th scope="col"><?php echo __('expiry'); ?></th>
                <th scope="col" class="col_amount"><?php echo __('price'); ?></th>
                <th scope="col"><?php echo __('quantity'); ?></th>
                <th scope="col"><?php echo __('image'); ?></th>
                <th scope="col" class="last"><?php echo __('actions'); ?></th>
            </tr>
            <?php foreach ($tickets as $ticket): ?>
                <tr class="hoverall" title="<?php echo __('tags') . ": " . join_tags($ticket->id); ?>">
                    <td class="first"><?php echo $ticket->id; ?></td>
                    <td nowrap="nowrap"><?php echo $ticket->ticket_name; ?></td>
                    <td nowrap="nowrap"><?php echo $category[$ticket->cat_id]; ?></td>
                    <td><?php echo $ticket->expiry_date; ?></td>
                    <td class="col_amount"><?php echo format_currency($ticket->price); ?></td>
                    <td><?php echo $ticket->quantity; ?></td>
                    <td style="vertical-align: middle;">
                        <?php if ($ticket->img_id != NULL && $ticket->img_id > 0): ?>
                            <?php if (isset($image[$ticket->img_id])): ?>
                                <img src="<?php echo base_url(); ?>uploads/images/<?php echo MODULE_NAME; ?>/thumbnail/<?php echo $image[$ticket->img_id]; ?>"/>
                            <?php else: ?>
                                <img src="<?php echo base_url(); ?>assets/images/no_img.png"/>
                            <?php endif; ?>
                        <?php else: ?>
                            <img src="<?php echo base_url(); ?>assets/images/no_img.png"/>
                        <?php endif; ?>
                    </td>
                    <td>
                        <a href="javascript:void(0);" onclick="submit_ticket(<?php echo $ticket->id; ?>, 'edit');"><?php echo get_icon('edit'); ?></a>
                        &nbsp;&nbsp;
                        <a href="javascript:void(0);" onclick="submit_ticket(<?php echo $ticket->id; ?>, 'delete');"><?php echo get_icon('delete'); ?></a>
                    </td>
                </tr>
            <?php endforeach; ?>
        </table>
        <div id="pagination"><?php echo isset($pagination) ? $pagination : NULL; ?></div>
    </div>       
</div>
<!--        edit or delete by submit this form below-->
<?php
echo form_open('', array('id' => 'ticket_list_form'), array('ticket_id' => 0, 'IS_FROM_LIST' => true));
echo form_close();
?>
<!--        edit or delete by submit this form below-->
<script>
    function submit_ticket(id, action)
    {
        $('input[name=ticket_id]').val(id);
        if (action=='delete')
            if ( !confirm('<?php echo __('do_you_really_wanna_delete'); ?>'))
        return;
        $('#ticket_list_form').attr('action', '/ticket-admin/' + action);
        $('#ticket_list_form').submit();
    }
</script>

